package cn.sofwin.demo.web.service.impl;

import cn.sofwin.core.dao.BaseDao;
import cn.sofwin.core.service.impl.BaseServiceImpl;
import cn.sofwin.demo.web.dao.UserDao;
import cn.sofwin.demo.web.entity.User;
import cn.sofwin.demo.web.service.UserService;

/**
 * 用户服务接口的实现
 * @author LetCode
 * @since 1.0
 */
public class UserServiceImpl extends BaseServiceImpl<User> implements UserService {

    /** 用户数据访问对象 */
    private UserDao userDao = new UserDao();

    /** 私有的实例对象，用户实现单例模式 */
    private static UserServiceImpl userService = new UserServiceImpl();

    /**
     * 将构造方法设为私有，用于实现单例模式
     */
    private UserServiceImpl(){
        super();
    }

    /**
     * 对外提供的静态方法，用于获取服务实例
     * @return
     */
    public static UserService getInstance(){
        return userService;
    }


    @Override
    protected BaseDao<User> getDao() {
        return userDao;
    }

    @Override
    public User login(String username, String password) {
        return userDao.selectByUsername(username);
    }
}
